package com.cc.ndmall.config.controller;

import com.cc.ndmall.common.utils.PageUtils;
import com.cc.ndmall.common.utils.R;
import com.cc.ndmall.config.entity.SystemEntity;
import com.cc.ndmall.config.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 系统配置表
 *
 * @author yaochenzhou
 * @email sunlightcs@gmail.com
 * @date 2020-11-07 10:33:28
 */
@RestController
@RequestMapping("config/system")
public class SystemController {
    @Autowired
    private SystemService systemService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("config:system:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = systemService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("config:system:info")
    public R info(@PathVariable("id") Integer id){
		SystemEntity system = systemService.getById(id);

        return R.ok().put("system", system);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("config:system:save")
    public R save(@RequestBody SystemEntity system){
		systemService.save(system);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("config:system:update")
    public R update(@RequestBody SystemEntity system){
		systemService.updateById(system);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("config:system:delete")
    public R delete(@RequestBody Integer[] ids){
		systemService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
